package com.coocaa.ops.admin.v1.auth.sys.util;

import com.coocaa.ops.admin.base.language.CommonLanguageProperties;
import com.coocaa.ops.common.core.biz.auth.entity.SysMenuEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;

/**
 * @author bijiahao
 * @date : 2019/3/22.
 * @description
 */
public class SysMenuValidator {
    private static CommonLanguageProperties commonLanguageProperties;

    public static void valid(SysMenuEntity entity) {
        Assert.notNull(entity, "menu" + commonLanguageProperties.getNotNull());
        Assert.hasText(entity.getMenuName(), "menuName" + commonLanguageProperties.getNotNull());
        Assert.hasText(entity.getMenuToken(), "menuToken" + commonLanguageProperties.getNotNull());
        Assert.notNull(entity.getPid(), "pid parentMenuID" + commonLanguageProperties.getNotNull());
    }

    @Autowired
    public void setCommonLanguageProperties(CommonLanguageProperties commonLanguageProperties) {
        SysMenuValidator.commonLanguageProperties = commonLanguageProperties;
    }

}

